package com.wing.sys.dao;

import java.util.List;

import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.stereotype.Repository;

import com.wing.common.CommonSpringJDBC;
import com.wing.sys.domain.RoleUser;

@Repository
public class RoleUserDao extends CommonSpringJDBC<RoleUser, String> {

	public List findRoleUser(RoleUser ru) {
		String sql = "select ru.* from sys_role_user ru where ru.roleid=:roleid and ru.userid=:userid ";
		return super.getSimpleJdbcTemplate().queryForList(sql, new BeanPropertySqlParameterSource(ru));
	}

	public void deleteRoleUser(String userid, String roleid) {
		String sql = "delete from sys_role_user  where roleid='"+roleid+"' and userid='"+userid+"'";
		super.getSimpleJdbcTemplate().update(sql);
	}

	public void deleteRoleUserByUserId(String userid) {
		String sql = "delete from sys_role_user  where userid='"+userid+"'";
		super.getSimpleJdbcTemplate().update(sql);
	}

	public void deleteRoleUserByRoleId(String roleId) {
		String sql = "delete from sys_role_user  where roleid='"+roleId+"'";
		super.getSimpleJdbcTemplate().update(sql);
	}
	

}
